-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Throw directly instead of replacing error handler in ext/date #6954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
63b440f
to
7988eaf
Compare
ext/date/php_date.c
Outdated
if ((flags & PHP_DATE_INIT_CTOR) && err && err->error_count) { | ||
/* spit out the first library error message, at least */ | ||
php_error_docref(NULL, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", time_str, | ||
zend_throw_error(zend_ce_exception, "Failed to parse time string (%s) at position %d (%c): %s", time_str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be zend_throw_exception_ex, same for the others.
ext/date/php_date.c
Outdated
@@ -4109,19 +4102,17 @@ PHP_FUNCTION(date_interval_format) | |||
} | |||
/* }}} */ | |||
|
|||
static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, /*const*/ char *format, size_t format_length) /* {{{ */ | |||
static void date_period_initialize(timelib_time **st, timelib_time **et, timelib_rel_time **d, zend_long *recurrences, /*const*/ char *format, size_t format_length) /* {{{ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would have been nicer to retain the return value and check that instead of EG(exception).
7988eaf
to
dc6703c
Compare
if ((flags & PHP_DATE_INIT_CTOR) && err && err->error_count) { | ||
/* spit out the first library error message, at least */ | ||
php_error_docref(NULL, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", time_str, | ||
zend_throw_exception_ex(NULL, 0, "Failed to parse time string (%s) at position %d (%c): %s", time_str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I keep E_WARNING
as the Exception code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we don't use exception codes.
Those branches and/or functions are only called from the OOP/constructor API as such there is no need to use
zend_replace_error_handling()
.One usage of this remains in the
timezone_initialize()
which could have a parameter added to signal if it should throw directly.